﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using ReflectionStudio.Core.Events;
using INTEX.DataBase;
using INTEX.DataBase.Tools;
using Intex.Tools;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{

    public class JLTVK05APPData : BaseFunction
    {
        public bool checkVK07 = true;
        SETINTEXDB INTEXDB = new SETINTEXDB();
        private Convert2Intex Convert2Intex;
        public DataSet SetCAD;
        INTEXDBC INTEXDBC;
        public JLTVK05APPData()
            : base()
        {

        }
        public JLTVK05APPData(OracleConnection _myConnection, IntexReptServBLClient _proxy, string userID = "        ")
            : base(_myConnection, _proxy, userID)
        {
            INTEXDBC = new INTEXDBC(OracleDB, proxy);
            Convert2Intex = new Convert2Intex();
            
        }
        public JLTVK05APPData(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {
            INTEXDBC = new INTEXDBC(OracleDB, proxy);
            Convert2Intex = new Convert2Intex();
        }
        public DataSet GetData(DataRow dwInput)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();

            try
            {
                DataRow dwTemp; 
                dwTemp = INTEXDB.VKPOS.NewRow();
                dwTemp["VKPMANDANT"] = dwInput["VKKMANDANT"];
                dwTemp["VKPAUFKRS"] = dwInput["VKKAUFKRS"];
                dwTemp["VKPAUFLFD"] = dwInput["VKKAUFLFD"];
                SResult = INTEXDBC.QueryVKPOS(dwTemp, 6);
                SReturn.Merge(SResult);
               
            }
            catch (Exception ex)
            {
                Tracer.Error(ABPOS + ex.StackTrace, ex);
            }
            finally
            {
                EventDispatcher.Instance.RaiseStatus("查询完成", StatusEventType.StopProgress);
            }
            return SReturn;
        }  
        public override DataSet LogIn(string MANDANT, string UsingID, System.Security.SecureString sPassword)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult;
            DataTable tableLocal = null;
            OracleCommand or1;
            try
            {
                IntPtr p = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(sPassword);
                string Password = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(p);
                UsingID = UsingID.Trim().ToUpper();
                Password = Password.Trim().ToUpper();
                DataRow dwTemp = INTEXDB.HRSTAMM.NewRow();
                dwTemp["HRMANDANT"] = MANDANT;
                dwTemp["HRBENID"] = Left(UsingID + "                    ", 8);
                dwTemp["HRDFAX"] =Left(Password+"                    ",20);
                SResult = INTEXDBC.QueryHRSTAMM(dwTemp, 1);
                SReturn.Merge(SResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex); ;
            }
            return SReturn;
        }
    }
}